package com.example.controller;

import com.example.domain.dto.PermissionDirectoryDto;
import com.example.domain.vo.PermissionDirectoryResVO;
import com.example.entity.PermissionDirectory;
import com.example.service.PermissionDirectoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 存储引擎为InnoDB，字符集为utf8(PermissionDirectory)表控制层
 *
 * @author makejava
 * @since 2025-02-23 23:17:50
 */
@RestController
public class PermissionDirectoryController {
    /**
     * 服务对象
     */

    @Resource
    private PermissionDirectoryService permissionDirectoryService;

    /**
     * 查询所有数据
     * @return 所有数据
     */
    @GetMapping("/selectList")
    public List<PermissionDirectoryResVO> selectList(){
        return permissionDirectoryService.selectList();
    }

    /**
     * 根据id查询数据
     * @param id id
     * @return 单条数据
     */
    @GetMapping("/{id}")
    public PermissionDirectory selectList(@PathVariable("id") Integer id){
        return permissionDirectoryService.getById(id);
    }

    /**
     * 添加数据
     * @param dto 数据传输对象
     */
    @PostMapping("/add")
    public void add(@RequestBody PermissionDirectoryDto dto){
        // 调用permissionDirectoryService的add方法，将数据传输对象dto传入
        permissionDirectoryService.add(dto);
    }

}

